﻿<phone:PhoneApplicationPage 
    x:Class="Groovy_IM.ChatPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="728"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="PortraitOrLandscape"  Orientation="Portrait"
    shell:SystemTray.IsVisible="False" OrientationChanged="PhoneApplicationPage_OrientationChanged">

    <Grid x:Name="LayoutRoot" Background="Transparent">
        <!--Pivot Control-->
        <controls:Pivot Title="Groovy IM" x:Name="pivSwitch" SelectionChanged="pivSwitch_SelectionChanged">
            <!--"Room" Item One-->
            <controls:PivotItem Header="Room">
                <ListBox x:Name="roomChat" Margin="0,0,-12,0">
                    <StackPanel Orientation="Horizontal" Margin="0,0,0,17">
                        <StackPanel Width="455" x:Name="roomWidth">
                            <ListBox x:Name="roomText" ItemsSource="{Binding Items}" Margin="0,0,0,0" MaxHeight="460" ManipulationCompleted="roomText_ManipulationCompleted">
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <StackPanel>
                                            <Border Background="{Binding BackUserColor}" BorderThickness="3" Margin="0,0,0,0" Height="60" Width="455">
                                                <TextBlock Text="{Binding Username}" Foreground="White" FontSize="{StaticResource PhoneFontSizeLarge}" VerticalAlignment="Center" HorizontalAlignment="Center" />
                                            </Border>
                                            <Border Background="{Binding BackUserColor}" BorderThickness="3" Margin="0,-10,0,10" MinHeight="60" Width="455">
                                                <TextBlock Text="{Binding UserText}" Foreground="White" FontSize="{StaticResource PhoneFontSizeNormal}" VerticalAlignment="Center" HorizontalAlignment="Center" TextWrapping="Wrap" />
                                            </Border>
                                        </StackPanel>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>
                            <TextBox Margin="0,20,0,0" Visibility="Visible" x:Name="roomSend" InputScope="chat" />
                        </StackPanel>
                    </StackPanel>
                </ListBox>
            </controls:PivotItem>

            <!--"People List" Item Two-->
            <controls:PivotItem Header="People">
                <ListBox x:Name="peopleList" ItemsSource="{Binding Items}" Margin="0,0,-12,0">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <Border Background="{StaticResource PhoneAccentBrush}" BorderThickness="3" Margin="0,0,0,0" Height="60" Width="455" DoubleTap="Border_Tap" Hold="Border_Hold">
                                    <TextBlock Text="{Binding BuddyName}" FontSize="{StaticResource PhoneFontSizeLarge}" Margin="0,0,0,0" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" />
                                    <toolkit:ContextMenuService.ContextMenu>
                                        <toolkit:ContextMenu>
                                            <toolkit:MenuItem Header="Invite Contact" Tag="{Binding BuddyName}" Click="inviteContact_Click" x:Name="inviteContact"/>
                                            <toolkit:MenuItem Header="Send Instant Message" Tag="{Binding BuddyName}" Click="sendIM_Click" x:Name="sendIM"/>
                                            <toolkit:MenuItem Header="View Profile" Tag="{Binding BuddyName}" Click="viewProfile_Click" x:Name="viewProfile"/>                                            
                                        </toolkit:ContextMenu>
                                    </toolkit:ContextMenuService.ContextMenu>
                                </Border>                                
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </controls:PivotItem>
        </controls:Pivot>

        <Canvas Height="270" HorizontalAlignment="Left" Margin="0" x:Name="inviteContactCanvas" VerticalAlignment="Top" Width="480" Background="{StaticResource PhoneAccentBrush}" Visibility="Collapsed">
            <TextBlock Text="Contacts Username" Margin="100,0,0,0" FontSize="32"/>
            <TextBox Name="contact" Width="470" Margin="0,40,0,0" />
            <TextBlock Text="Invite Message" Margin="130,100,0,0" FontSize="32"/>
            <TextBox Name="invMsg" Width="470" Margin="0,140,0,0" Text="Come Join Me!" TextAlignment="Center" GotFocus="invMsg_GotFocus" LostFocus="invMsg_LostFocus" />
            <Button Name="Invite" Content="Invite Contact" Width="470" Margin="0,200,0,0" Click="Invite_Click" />
        </Canvas>

    </Grid>

    <!--Sample code showing usage of ApplicationBar-->
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton x:Name="send_Message" IconUri="/Images/App/AppBar/appbar.feature.send.im.png" Text="send" Click="send_Message_Click"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem x:Name="mnuClearRoom" Text="clear" Click="mnuClearRoom_Click"/>
                <shell:ApplicationBarMenuItem x:Name="mnuClose" Text="close" Click="mnuClose_Click"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>
    
</phone:PhoneApplicationPage>